package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.entity.Setmeal;
import com.itheima.mapper.SetmealMapper;
import com.itheima.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: fan
 * @Desc: 套餐模块
 * @Date: 2022/6/5 11:45
 */
@Service
public class SetmealServiceImpl implements SetmealService {
    @Autowired
    private SetmealMapper setmealMapper;


    /**
     * 功能描述: 套餐数据回显
     *
     * @param categoryId
     * @param status
     * @return : java.util.List<com.itheima.entity.Setmeal>
     */
    @Override
    public List<Setmeal> list(Long categoryId, Integer status) {
        List<Setmeal> setmeals = new ArrayList<>();
        if (categoryId == null || status == null) {
            return setmeals;
        }
        LambdaQueryWrapper<Setmeal> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Setmeal::getCategoryId, categoryId)
                    .eq(Setmeal::getStatus, status);
        setmeals = setmealMapper.selectList(queryWrapper);
        return setmeals;
    }
}
